/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/
define(["require", "exports"], function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    const directives = [
        {
            value: '@ts-check',
            description: 'Enables semantic checking in a JavaScript file. Must be at the top of a file.'
        }, {
            value: '@ts-nocheck',
            description: 'Disables semantic checking in a JavaScript file. Must be at the top of a file.'
        }, {
            value: '@ts-ignore',
            description: 'Suppresses @ts-check errors on the next line of a file.'
        }
    ];
    class DirectiveCommentCompletionProvider {
        constructor(client, vscode) {
            this.client = client;
            this.vscode = vscode;
        }
        provideCompletionItems(document, position, _token) {
            if (!this.client.apiVersion.has230Features()) {
                return [];
            }
            const file = this.client.normalizePath(document.uri);
            if (!file) {
                return [];
            }
            const line = document.lineAt(position.line).text;
            const prefix = line.slice(0, position.character);
            const match = prefix.match(/^\s*\/\/+\s?(@[a-zA-Z\-]*)?$/);
            if (match) {
                return directives.map(directive => {
                    const item = new this.vscode.CompletionItem(directive.value, this.vscode.CompletionItemKind.Snippet);
                    item.detail = directive.description;
                    item.range = new this.vscode.Range(position.line, Math.max(0, position.character - (match[1] ? match[1].length : 0)), position.line, position.character);
                    return item;
                });
            }
            return [];
        }
        resolveCompletionItem(item, _token) {
            return item;
        }
    }
    exports.default = DirectiveCommentCompletionProvider;
});
